<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="author" content="wangbo">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>BOM</title>
</head>

<body>
  <a href="chp12-02.html?name=战三">访问本地</a>
  <a href="chp12-02.html#top">锚点</a>
  <button onclick="fn1()" >跳转</button>
  <button onclick="fn2()" >刷新</button>
  <button onclick="fn3()" >替换</button>
  <!-- location 网址 -->
  <script>
    let fn1 = () => {
      // 完整的url路径
      console.log(location.href)
      // 设置网址
      // 
      // location.href="http://www.aaaaacccc.com:80?name=战三"
      // 网址用的协议
      console.log(location.protocol)
      // www.aaaaacccc.com:80
      console.log(location.host)
      // www.aaaaacccc.com
      console.log(location.hostname)
      // http://www.aaaaacccc.com
      console.log(location.pathname)
      // name=战三
      console.log(location.search)
      // 锚点
      console.log(location.hash)
    }
    let fn1 = () => {
      // 跳转到指定的页面
      location.assign("http://www.baidu.com")
    }
    // fn1();
    let fn2 = function () {
      // 重新加载页面,刷新页面
      location.reload();
    }
    console.log(Math.random())
    // 替换将当前的网址换掉,并没有页面的跳转,也就没有浏览器的历史记录
    function fn3() {
      location.replace("http://www.baidu.com")
    }
    fn1()
  </script>
</body>

</html>